This application relates to a compiler and, specifically, to the maintenance and design of a compiler for a high level computer programming language.
A compiler is a computer program that translates a "source program" written in a high level computer programming language that is easily understood by human beings into a "target program" executable by a computer. Typically, a compiler includes several functional parts. For example, a conventional compiler may include a lexical analyzer that looks at the source program and identifies successive "tokens" in the source program.
A conventional compiler also includes a parser/syntactical analyzer, which takes as an input a grammar defining the language being compiled and a series of actions associated with respective production of the grammar. The parser builds a "parse tree" for the statements in the source program in accordance with the grammar productions and actions. For each statement in the input source program, the parser generates a parse tree of the source input in a recursive, "bottom-up" manner in accordance with relevant productions and actions. Thus, the parse tree is formed of nodes corresponding to one or more grammar productions. Generation of the parse tree allows the parser to determine whether the parts of the source program comply with the grammar. If not, the parser generates an error. Thus, the parser performs syntactical checking, but does not conventionally check the meaning (the "semantics") of the source program. One example of a conventional parsing technique is a LALR (lookahead, left right) parser, which is described in Chapter 4 of the treatise "Compilers: Principles, Techniques and Tools" by Aho, Sethi, and Ullman, the entirety of which is hereby incorporated by reference.
In conventional compilers, after the source program is parsed, it is input to a semantic analyzer, which checks for semantic errors, such as the mismatching of types, etc. The semantic analyzer evaluates, for example, "semantic attributes" of nodes of the parse tree. Attributes that are evaluated by looking at the attributes of their child nodes are called "synthesized attributes." After parsing and semantic analysis, the compiler generates intermediate code, optimizes the intermediate code and generates a target program.
The source program of a compiler software program itself is quite large and complex. Many different people usually work on the source code of a compiler during the compiler's useful life. Thus, different people with different coding styles, some good and some bad, contribute to the source code of a compiler. Even if every programmer contributing to the source code of a compiler uses good programming practices (which is unlikely) individual programming style vary and most compilers are written in a variety of coding styles. It is important that the source code for a compiler be easy to update and to maintain.
To this end, it is important to standardize the modules of the source program and to standardize the interfaces between modules. Earlier efforts to standardize coding practices include ADT (Abstract Data Types) and OOP (object oriented programming) methodologies.